  var websocket = null;
  //判断当前浏览器是否支持WebSocket
  if('WebSocket' in window){
  websocket = new WebSocket("ws://192.168.19.96:8080/haipumi_pro/backadmin/ServiceInfo");
  }
  else{
      alert('Not support websocket')
  }
   
  //连接发生错误的回调方法
  websocket.onerror = function(){
//      setMessageInnerHTML("error");
  };
   
  //连接成功建立的回调方法
  websocket.onopen = function(event){
//      setMessageInnerHTML("open");
  }
   
  //接收到消息的回调方法
  websocket.onmessage = function(e){
	  var a=e||window.event
      setMessageInnerHTML(a.data);
  }
   
  //连接关闭的回调方法
  websocket.onclose = function(){
//      setMessageInnerHTML("close");
  }
   
  //监听窗口关闭事件，当窗口关闭时，主动去关闭websocket连接，防止连接还没断开就关闭窗口，server端会抛异常。
  window.onbeforeunload = function(){
      websocket.close();
  }
   
  //将消息显示在网页上
  function setMessageInnerHTML(innerHTML){
	  //alert(innerHTML);
	  var data=jQuery.parseJSON(innerHTML)//将json字符串转为对象
	  
	  $("#yhj_ip").html(data.ip);
	  $("#yhj_computername").html(data.computername);
	  $("#yhj_javaversion").html(data.javaversion);
	  $("#yhj_cpunum").html(data.cpunum);
	  $("#yhj_systemname").html(data.systemname);
	  $("#yhj_systemversion").html(data.systemversion);
	  $("#yhj_userdocument").html(data.userdocument);
	  
	  $('.percentage, .percentage-light').eq(0).each(function() {
			var newValue = (data.romuse/data.romtotal*100	).toFixed(1);
			$(this).data('easyPieChart').update(Math.round(newValue));
			$('span', this).text(newValue);
		  });
		$('.percentage, .percentage-light').eq(1).each(function() {
			var newValue=(data.cpuuse*100	).toFixed(1);
			if(newValue>100.0){
				newValue=100.0;
			}
			$(this).data('easyPieChart').update(Math.round(newValue));
			$('span', this).text(newValue);
		  });
		for(var i=0;i<data.disklist.length;i++){
			var yhj_percentage=$(".percentage").eq(data.disklist.length+1).html();
			if(yhj_percentage!="<span></span>"){
				$("#serviceinfochart").append("<div class=\"chart\"><div class=\"percentage\" data-percent=\"50\"><span></span></div><div class=\"label\">"+data.disklist[i].name+"占用率<font color='red'>"+(data.disklist[i].usedsize*100/data.disklist[i].totalsize).toFixed(1)+"%</font></div></div>");
				
			}
		}
  }
   
  //关闭连接
  function closeWebSocket(){
      websocket.close();
  }
   
  //发送消息
  function sendChatInfo(obj){
//	  var context=$(obj).prev().val();
//	  var time=DateDemo();
//	  //发送人ID,接收人ID-MESSAGE
//	  //var message=$("#lk_cool_effects_chatDiv_ID").attr("selfid")+","+$("#lk_cool_effects_chatDiv_ID").attr("userid")+"-"+context;
//	  var message=context;
//	  $(".lk_cool_effects_chatDiv_contents_right_message_chat").append('<div><div class="lk_cool_message_chat_user">'+time+' 您 :</div><div class="lk_cool_message_chat_user_message">'+context+'</div></div>');
//      websocket.send(message);
//	  $(obj).prev().val("");
  }
  
 